package net.lab1024.sa.admin.module.users.inventorycheck.controller;

import net.lab1024.sa.admin.module.users.inventorycheck.domain.form.InventoryCheckAddForm;
import net.lab1024.sa.admin.module.users.inventorycheck.domain.form.InventoryCheckQueryForm;
import net.lab1024.sa.admin.module.users.inventorycheck.domain.form.InventoryCheckUpdateForm;
import net.lab1024.sa.admin.module.users.inventorycheck.domain.vo.InventoryCheckVO;
import net.lab1024.sa.admin.module.users.inventorycheck.service.InventoryCheckService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 库存盘点 Controller
 *
 * @Author lyy
 * @Date 2024-12-10 23:31:13
 * @Copyright lyy
 */

@RestController
@Tag(name = "库存盘点")
public class InventoryCheckController {

    @Resource
    private InventoryCheckService inventoryCheckService;

    @Operation(summary = "分页查询 @author lyy")
    @PostMapping("/inventoryCheck/queryPage")
    @SaCheckPermission("inventoryCheck:query")
    public ResponseDTO<PageResult<InventoryCheckVO>> queryPage(@RequestBody @Valid InventoryCheckQueryForm queryForm) {
        return ResponseDTO.ok(inventoryCheckService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author lyy")
    @PostMapping("/inventoryCheck/add")
    @SaCheckPermission("inventoryCheck:add")
    public ResponseDTO<String> add(@RequestBody @Valid InventoryCheckAddForm addForm) {
        return inventoryCheckService.add(addForm);
    }

    @Operation(summary = "更新 @author lyy")
    @PostMapping("/inventoryCheck/update")
    @SaCheckPermission("inventoryCheck:update")
    public ResponseDTO<String> update(@RequestBody @Valid InventoryCheckUpdateForm updateForm) {
        return inventoryCheckService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author lyy")
    @PostMapping("/inventoryCheck/batchDelete")
    @SaCheckPermission("inventoryCheck:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return inventoryCheckService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author lyy")
    @GetMapping("/inventoryCheck/delete/{id}")
    @SaCheckPermission("inventoryCheck:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return inventoryCheckService.delete(id);
    }
}
